<template>
	<view>	
		<view class="page-container" style="position: relative;">
			<view class="content">
				<view class="poster-image"><image v-if="posterSrc" :src="$wanlshop.oss(posterSrc, 40, 40)"></image></view>				
			</view>
			<view class="page-foot">
				<view class="template-list">
					
					<!-- #ifdef H5 -->
						<view class="tips text-sm wanl-gray">
							<text class="wlIcon-31tishi"></text> 长按图片保存
						</view>
					<!-- #endif -->
					<!-- #ifndef H5 -->
						<view class="tips text-sm wanl-orange" @tap="save()">
							<text class="wlIcon-image margin-right-xs"></text>保存到相册
						</view>
					<!-- #endif -->
				</view>
			</view>
			<view style="text-align: center;font-size: 40rpx;">
				请向商家展示二维码即可提货
			</view>
		</view>
		
	</view>
</template>

<script>
import jssdk from '../../../common/libs/jssdk';
import uQRCode from '@/common/uqrcode.js';

export default {
	data() {
		return {
			text:'',
			posterSrc:''
		};
	},
	onLoad(option) {
		this.text = option.text;		
		this.loadData();
	},
	methods: {	
		
		// 二维码配置
		async loadData(option) {
			
			await uni.request({
				url: '/wanlshop/ddporder/takeqrcode',
				method: 'POST',
				data:{text:this.text},
				success: res => {
					console.log(res);
					this.posterSrc = res.data.url;
				}
			});
		},	
		save() {
			uni.saveImageToPhotosAlbum({
				filePath: this.posterSrc,
				success: () => {
					this.$wanlshop.msg('保存成功');
				}
			});
		}
	}
};
</script>

<style>
.page-background {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 10;
	background-color: #f1f1f1;
}



.content {
	width:  600rpx;
	height: 600rpx;
	margin: auto;
}

.poster-image {
	width: 100%;
	height: 100%;
	min-height: 500rpx;
	padding: 80rpx;
	box-sizing: border-box;
}

.poster-image image {
	width: 100%;
	height: 100%;
}

.poster-canvas {
	position: fixed;
	right: 100vw;
	bottom: 100vh;
}

.page-foot {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 30;	
	padding-bottom: env(safe-area-inset-bottom);
}

.template-list {
	display: flex;
	position: relative;
	height: 100px;
}
.template-list .tips {	
	display: flex;
	align-items: center;
	justify-items: center;
	justify-content: center;
	top: -60rpx;
	width: 100%;
}
.template-list .tips .wlIcon-31tishi{
	font-size: 32rpx;
}
.template-item {
	position: relative;
	height: 88px;
	margin: 6px 0 6px 6px;
}

.template-item::before {
	content: '';
	position: absolute;
	z-index: 10;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}

.template-item.checked::before {
	border: 2px solid #44aa33;
}

.template-item image {
	display: block;
	width: 100%;
	height: 100%;
}
</style>
